# coding=utf-8
import re

# 常用匹配符.的使用：匹配任意一个字符（除了\n）
pattern = "."
str = "9"
# str = "a"
# str = "B"
# str = "_"
print(re.match(pattern, str))
# 常用匹配符\d的使用：匹配数字
pattern = "\d"
str = "0"
# str = "a"
# str = "B"
# str = "_"
print(re.match(pattern, str))
# 常用匹配符\D的使用：匹配非数字
pattern = "\D"
str = "a"
# str = "B"
# str = "_"
print(re.match(pattern, str))
# 常用匹配符\s的使用：匹配空白字符,即空格（\n,\t）
pattern = "\s"
str = " "
str = "\n"
# str = "\t"
print(re.match(pattern, str))
# 常用匹配符\S的使用：匹配不是空白的字符
pattern = "\S"
str = "a"
# str = "B"
# str = "_"
print(re.match(pattern, str))
# 常用匹配符\w的使用：匹配字母、数字、下划线
pattern = "\w"
str = "a"
# str = "8"
# str = "_"
print(re.match(pattern, str))
# 常用匹配符\W的使用：W匹配不是字母、数字、下划线
pattern = "\W"
str = "#"
# str = "@"
# str = "_"
print(re.match(pattern, str))
# []匹配列表中的字符
pattern = "[12345]"
str = "1"
# str = "2"
# str = "3"
print(re.match(pattern, str))
# 匹配手机号码
s = "13456788789"
pattern = "1[35789]\d\d\d\d\d\d\d\d\d"
print("匹配手机号码：", re.match(pattern, s))
